Your application can use the DeviceLoop procedure (described on DeviceLoop ) before drawing images that are optimized for every screen they cross. The DeviceLoop procedure searches for video devices that intersect your drawing region, and it calls a drawing procedure that you define for every different video device it finds.
For each video device that intersects a drawing region that you define (generally, the update region of a window), DeviceLoop calls your drawing procedure. Because DeviceLoop provides your drawing procedure with the pixel depth and other attributes of the current device, your drawing procedure can optimize its drawing for whatever type of graphics device is the current device. When highlighting, for example, your application might invert black and white when drawing onto a 1-bit video device but use magenta as the highlight color when drawing onto a color video device. In this case, even were your window to span both a black-and-white and a color screen, the user sees the selection inverted on the black-and-white screen, while magenta would be used to highlight the selection on the color screen.
You must provide a pointer to your drawing procedure in the drawingProc parameter for DeviceLoop .
Here's how to declare a drawing procedure to supply to the DeviceLoop procedure if you were to name the procedure MyDrawingProc :
PROCEDURE MyDrawingProc (depth: Integer; deviceFlags: Integer;
targetDevice: GDHandle;
userData: LongInt);
CONST {flag bits for gdFlags field of GDevice record}
gdDevType = 0; {if bit is set to 1, graphics }
{ device supports color}
burstDevice = 7; {if bit is set to 1, device }
{ supports block transfer}
ext32Device = 8; {if bit is set to 1, device }
{ must be used in 32-bit mode}
ramInit = 10; {if bit is set to 1, device has }
{ been initialized from RAM}
mainScreen = 11; {if bit is set to 1, device is }
{ the main screen}
allInit = 12; {if bit is set to 1, all }
{ devices were initialized from }
{ 'scrn' resource}
screenDevice = 13; {if bit is set to 1, device is }
{ a screen}
noDriver = 14; {if bit is set to 1, GDevice }
{ record has no driver}
screenActive = 15; {if bit is set to 1, device is }
{ active}
Your drawing procedure should analyze the pixel depth passed in the depth parameter and the values passed in the deviceFlags parameter, and then draw in a manner that is optimized for the current device.
Listing 2 illustrates a simple drawing procedure called by DeviceLoop .